// 新消息提醒
var titleInit = document.title,
  isShine = true;

setInterval(function () {
  var title = document.title;
  if (isShine == true) {
    if (/新/.test(title) == false) {
      document.title = '【你有新消息】';
    } else {
      document.title = '【　　　　　】';
    }
  } else {
    document.title = titleInit;
  }
}, 500);

window.onfocus = function () {
  isShine = false;
};
window.onblur = function () {
  isShine = true;
};

// for IE
document.onfocusin = function () {
  isShine = false;
};
document.onfocusout = function () {
  isShine = true;
};
// 日历
// var myCalendar = new SimpleCalendar("#calendar");
// 日历标记点击
// $(".sc-mark").on("click", function () {
//   var value = $(this).attr("title");
//   if (value == "" || value == undefined || value == null) {
//     return;
//   } else {
//     layer.tips(value, $(this));
//   }
// });
// 找人查询
var userGridColumns = [{
    id: 'userName',
    title: '姓名',
    width: 80,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'userSex',
    title: '性别',
    width: 50,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'leadership',
    title: '直接领导',
    width: 80,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'department',
    title: '部门',
    width: 200,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'jobs',
    title: '岗位',
    width: 200,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'tell',
    title: '联系方式',
    width: 100,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'email',
    title: '邮箱地址',
    type: 'string',
    columnClass: 'text-center',
  }
];
var userGridOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  // check: true,
  // checkWidth: '37px',
  exportFileName: '员工信息',
  datas: [{
    userName: '张三',
    userSex: '男',
    leadership: '李四',
    department: '柔性融合运维平台研发部',
    jobs: '董事长助理兼执行副总裁',
    tell: '12345678901',
    email: 'zhangsan@certusnet.com'
  }],
  columns: userGridColumns,
  gridContainer: 'userDataGird',
  toolbarContainer: 'userGridToolBarContainer',
  tools: '',
  pageSize: 1,
  pageSizeLimit: [1, 5]
};
var userGird = $.fn.dlshouwen.grid.init(userGridOption);
$(function () {
  userGird.load();
});
// 待办管理
var thingsGridColumns = [{
    id: 'title',
    title: '标题',
    width: 100,
    type: 'string',
    columnClass: 'text-center',
  },
  {
    id: 'content',
    title: '主要内容',
    type: 'string',
    columnClass: 'text-left',
  },
  {
    id: 'userName',
    title: '发起人',
    type: 'string',
    width: 80,
    columnClass: 'text-center',
  },
  {
    id: 'time',
    title: '提交时间',
    type: 'date',
    width: 100,
    format: 'yyyy-MM-dd',
    columnClass: 'text-center',
    hideType: 'md|sm|xs',
  },
  {
    id: 'operation',
    title: '操作',
    width: 70,
    type: 'string',
    columnClass: 'text-center',
    resolution: function (value, record, column, grid, dataNo, columnNo) {
      var content = '';
      content += '<button class="btn btn-xs btn-success" onclick="toDo(' + record.id + ',' + record.doType + ');"><i class="fa fa-edit"></i>  办理</button>';
      return content;
    }
  }
];
var thingsGridOption = {
  lang: 'zh-cn',
  ajaxLoad: false,
  // loadURL:'url',
  // check: true,
  // checkWidth: '37px',
  exportFileName: '事项管理',
  datas: [{
    id: 1,
    title: '线索申请',
    userName: '张三测试',
    content: '新增线索申请的批准',
    time: '9999-99-99',
    doType: 1,
  }, {
    id: 2,
    title: '线索申请',
    userName: '张三测试',
    content: '线索被退回的操作',
    time: '9999-99-99',
    doType: 2,
  }, {
    id: 3,
    title: '线索申请',
    userName: '张三测试',
    content: '线索批准通过后结果',
    time: '9999-99-99',
    doType: 3,
  },{
    id: 3,
    title: '线索申请',
    userName: '张三测试',
    content: '线索批准通过后结果',
    time: '9999-99-99',
    doType: 3,
  },{
    id: 3,
    title: '线索申请',
    userName: '张三测试',
    content: '线索批准通过的结果',
    time: '9999-99-99',
    doType: 3,
  }],
  columns: thingsGridColumns,
  gridContainer: 'thingsDataGird',
  toolbarContainer: 'thingsGridToolBarContainer',
  tools: '',
  pageSize: 10,
  pageSizeLimit: [10, 20]
};
var thingsGird = $.fn.dlshouwen.grid.init(thingsGridOption);
$(function () {
  thingsGird.load();
});

// 待办类型跳转
function toDo(id, doType) {
  if (doType == 1) {
    window.location.href = "/do/edit/edit-do-1.html" + '?id=' + id + '&doType=' + doType;
  }
  if (doType == 2) {
    window.location.href = "/do/edit/edit-do-2.html" + '?id=' + id + '&doType=' + doType;
  }
  if (doType == 3) {
    window.location.href = "/do/edit/edit-do-3.html" + '?id=' + id + '&doType=' + doType;
  }
}